package org.nfIt.controller;

import org.nfIt.dto.system.AssginMenuDto;
import org.nfIt.service.SysRoleMenuService;
import org.nfIt.vo.common.Result;
import org.nfIt.vo.common.ResultCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * ClossName:SysRoleMenuController
 * Pakage:org.nfIt.controller
 * Description
 *
 *
 * 角色和菜单管理
 *
 * @Author L
 * @Create 2024/7/17 20:32
 * @Version 2023.1.3
 */
@RestController
@RequestMapping(value = "/admin/system/sysRoleMenu")
public class SysRoleMenuController {


    @Autowired
    private SysRoleMenuService sysRoleMenuService ;

    /**
     * 查询所有菜单 和 查询角色分配过菜单id列表
     * @param roleId 角色id
     * @return
     */
    @GetMapping(value = "/findSysRoleMenuByRoleId/{roleId}")
    public Result<Map<String , Object>> findSysRoleMenuByRoleId(@PathVariable(value = "roleId") Long roleId) {
        Map<String , Object> sysRoleMenuList = sysRoleMenuService.findSysRoleMenuByRoleId(roleId) ;
        return Result.build(sysRoleMenuList , ResultCodeEnum.SUCCESS) ;
    }

    /**
     * 保存菜单
     * @param assginMenuDto
     */
    @PostMapping("/doAssign")
    public Result doAssign(@RequestBody AssginMenuDto assginMenuDto) {
        sysRoleMenuService.doAssign(assginMenuDto);
        return Result.build(null , ResultCodeEnum.SUCCESS) ;
    }

}
